package com.bang.study.singleton;

/**
 * @ClassName: SingletonExample1
 * @Desc: 单例模式 懒汉式 volatile + 双重检测机制
 * @author: BANG
 * @Date: 2019/10/28 11:59
 * @Version: 1.0
 * @Modified By:
 */
public class SingletonExample2 {

    private static volatile SingletonExample2 instance = null;

    private SingletonExample2() {
    }

    public static SingletonExample2 getInstance() {
        if (null == instance) {
            synchronized (SingletonExample2.class) {
                if (null == instance) {
                    instance = new SingletonExample2();
                }
            }
        }
        return instance;
    }
}
